const app = getApp()
const host = app.globalData.host

Page({
  data: {
    logoSrc: 'https://yuanjia-db.oss-cn-beijing.aliyuncs.com/%E7%A7%81%E4%BA%BA%E5%BE%8B%E5%B8%88%E5%B0%8F%E7%A8%8B%E5%BA%8F/accredit-logo.jpg',
    iconSrc: 'https://yuanjia-db.oss-cn-beijing.aliyuncs.com/%E7%A7%81%E4%BA%BA%E5%BE%8B%E5%B8%88%E5%B0%8F%E7%A8%8B%E5%BA%8F/accredit-icon.png',
  },
  onLoad: function (options) {
    // app.globalData.isLog()
  },

  getPhoneNumber: function (res) {
    // console.log(res.detail);
    var token = wx.getStorageSync("token");
    console.log(res.detail);
    // 发送请求获取手机号
    wx.request({
      url: host + '/users/mobile',
      method: 'post',
      header: {
        'content-type': 'application/json'
      },
      data:{
        encrypted: res.detail.encryptedData,
        iv: res.detail.iv,
        token:token
      },
      success: function (res) {
       console.log(res);
        wx.switchTab({
          url: '../danger/index',
        })
      },
      fail: function (res) {
        console.log(res);
        // console.log(res)
        wx.showToast({
          title: '获取手机号失败',
          icon: 'none',
          duration: 2000
        })
      }
    })
  }
})